home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 26 / Cream of the Crop 26.iso / os2 / octa209s.zip / octave-2.09 / liboctave / dDiagMatrix.h < prev    next >
C/C++ Source or Header  |  1996-10-12  |  3KB  |  119 lines

  1. /*
  2.  
  3. Copyright (C) 1996 John W. Eaton
  4.  
  5. This file is part of Octave.
  6.  
  7. Octave is free software; you can redistribute it and/or modify it
  8. under the terms of the GNU General Public License as published by the
  9. Free Software Foundation; either version 2, or (at your option) any
  10. later version.
  11.  
  12. Octave is distributed in the hope that it will be useful, but WITHOUT
  13. ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  14. FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  15. for more details.
  16.  
  17. You should have received a copy of the GNU General Public License
  18. along with Octave; see the file COPYING.  If not, write to the Free
  19. Software Foundation, 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
  20.  
  21. */
  22.  
  23. #if !defined (octave_DiagMatrix_h)
  24. #define octave_DiagMatrix_h 1
  25.  
  26. #if defined (__GNUG__)
  27. #pragma interface
  28. #endif
  29.  
  30. #include "MDiagArray2.h"
  31.  
  32. #include "dRowVector.h"
  33. #include "dColVector.h"
  34.  
  35. #include "mx-defs.h"
  36.  
  37. class DiagMatrix : public MDiagArray2<double>
  38. {
  39. friend class SVD;
  40. friend class ComplexSVD;
  41.  
  42. public:
  43.  
  44.   DiagMatrix (void) : MDiagArray2<double> () { }
  45.   DiagMatrix (int r, int c) : MDiagArray2<double> (r, c) { }
  46.   DiagMatrix (int r, int c, double val) : MDiagArray2<double> (r, c, val) { }
  47.   DiagMatrix (const RowVector& a) : MDiagArray2<double> (a) { }
  48.   DiagMatrix (const ColumnVector& a) : MDiagArray2<double> (a) { }
  49.   DiagMatrix (const MDiagArray2<double>& a) : MDiagArray2<double> (a) { }
  50.   DiagMatrix (const DiagMatrix& a) : MDiagArray2<double> (a) { }
  51.  
  52.   DiagMatrix& operator = (const DiagMatrix& a)
  53.     {
  54.       MDiagArray2<double>::operator = (a);
  55.       return *this;
  56.     }
  57.  
  58.   bool operator == (const DiagMatrix& a) const;
  59.   bool operator != (const DiagMatrix& a) const;
  60.  
  61.   DiagMatrix& fill (double val);
  62.   DiagMatrix& fill (double val, int beg, int end);
  63.   DiagMatrix& fill (const ColumnVector& a);
  64.   DiagMatrix& fill (const RowVector& a);
  65.   DiagMatrix& fill (const ColumnVector& a, int beg);
  66.   DiagMatrix& fill (const RowVector& a, int beg);
  67.  
  68.   DiagMatrix transpose (void) const;
  69.  
  70.   friend DiagMatrix real (const ComplexDiagMatrix& a);
  71.   friend DiagMatrix imag (const ComplexDiagMatrix& a);
  72.  
  73.   // resize is the destructive analog for this one
  74.  
  75.   Matrix extract (int r1, int c1, int r2, int c2) const;
  76.  
  77.   // extract row or column i.
  78.  
  79.   RowVector row (int i) const;
  80.   RowVector row (char *s) const;
  81.  
  82.   ColumnVector column (int i) const;
  83.   ColumnVector column (char *s) const;
  84.  
  85.   DiagMatrix inverse (void) const;
  86.   DiagMatrix inverse (int& info) const;
  87.  
  88.   // diagonal matrix by diagonal matrix -> diagonal matrix operations
  89.  
  90.   DiagMatrix& operator += (const DiagMatrix& a);
  91.   DiagMatrix& operator -= (const DiagMatrix& a);
  92.  
  93.   // diagonal matrix by diagonal matrix -> diagonal matrix operations
  94.  
  95.   friend DiagMatrix operator * (const DiagMatrix& a,
  96.                 const DiagMatrix& b);
  97.  
  98.   // other operations
  99.  
  100.   ColumnVector diag (void) const;
  101.   ColumnVector diag (int k) const;
  102.  
  103.   // i/o
  104.  
  105.   friend ostream& operator << (ostream& os, const DiagMatrix& a);
  106.  
  107. private:
  108.  
  109.   DiagMatrix (double *d, int nr, int nc) : MDiagArray2<double> (d, nr, nc) { }
  110. };
  111.  
  112. #endif
  113.  
  114. /*
  115. ;;; Local Variables: ***
  116. ;;; mode: C++ ***
  117. ;;; End: ***
  118. */
  119.